Qr code positioning method and apparatus

ABSTRACT

Implementations of the present application provide a QR code positioning method and apparatus. Based on a predetermined pixel detection rule, centers of candidate position detection patterns in the QR code image are determined from a QR code image that includes first-type pixels and second-type pixels. The predetermined pixel detection rule includes that a consecutive arrangement ratio of the first-type pixels, the second-type pixels, and the first-type pixels satisfies a predetermined ratio. The candidate position detection patterns are identified based on the centers of the candidate position detection patterns. A set of patterns that satisfies a QR code image positioning rule are determined from the candidate position detection patterns. The set of patterns are used as position detection patterns of the QR code image.

CROSS-REFERENCE TO RELATED APPLICATIONS

This application is a continuation of and claims the benefit of priorityof U.S. patent application Ser. No. 16/697,833, filed Nov. 27, 2019,which is a continuation of PCT Application No. PCT/CN2018/107318, filedon Sep. 25, 2018, which claims priority to Chinese Patent ApplicationNo. 201710888105.9, filed on Sep. 27, 2017, and each application ishereby incorporated by reference in its entirety.

TECHNICAL FIELD

The present application relates to the image processing field, and inparticular, to a QR code positioning method and apparatus.

BACKGROUND

A QR code is also referred to as a two-dimensional barcode. The QR coderecords data symbol information by using a pattern that is formed byarranging a specific type of geometric pattern in a plane(two-dimensional direction) based on a specific rule. Compared with aconventional barcode, the QR code is characterized by high informationcapacity, strong error correction capability, high decoding reliability,etc., and has advantages like low costs, easy to make, etc. Therefore,the QR code has been widely used in multiple fields, such as the paymentfield and the identity authentication field.

When a QR code is being used, after the QR code is scanned, the QR codeneeds to be identified to obtain data symbol information stored in theQR code. After a QR code pattern is scanned, a QR code is positioned anddecoded, to identify the QR code. In a related technology, positiondetection patterns in the QR code image are first identified, and thenthe QR code is positioned by using the position detection patterns.

In routine use of the QR code, a problem of poor recognition performanceoften occurs in some environments. For example, when position detectionpatterns of the QR code are slightly stained or are weak in brightness,the position detection patterns of the QR code often cannot beaccurately identified. As a result, the QR code cannot be positioned,and consequently the QR code fails to be identified. Therefore, a QRcode positioning method with relatively high accuracy and validity indifferent environments is urgently needed in the industry.

SUMMARY

An objective of the implementations of the present application is toprovide a QR code positioning method and apparatus, to achieverelatively high QR code positioning accuracy and validity, therebyimproving QR code recognition efficiency.

To resolve the previous technical problem, the implementations of thepresent application are implemented in the following way:

An implementation of the present application provides a QR codepositioning method, including: determining, from a QR code image thatincludes first-type pixels and second-type pixels, centers of candidateposition detection patterns in the QR code image based on apredetermined row pixel detection rule and a predetermined column pixeldetection rule, where the row pixel detection rule includes that aconsecutive arrangement ratio of a first-type pixel, a second-typepixel, and a first-type pixel satisfies a first predetermined ratio, andthe column pixel detection rule includes that a consecutive arrangementratio of a first-type pixel, a second-type pixel, and a first-type pixelsatisfies a second predetermined ratio; identifying the correspondingcandidate position detection patterns based on the determined centers ofthe candidate position detection patterns; and determining, from theidentified candidate position detection patterns, patterns that satisfya QR code image positioning rule, and using the determined patterns asposition detection patterns of the QR code image.

An implementation of the present application further provides a QR codepositioning method, including: determining, from a QR code image thatincludes first-type pixels and second-type pixels, centers of candidateposition detection patterns in the QR code image based on apredetermined row pixel detection rule and a predetermined column pixeldetection rule, where the row pixel detection rule includes that aquantity of consecutively arranged first-type pixels or a quantity ofconsecutively arranged second-type pixels reaches a first predeterminedthreshold, and the column pixel detection rule includes that a quantityof consecutively arranged first-type pixels or a quantity ofconsecutively arranged second-type pixels reaches a second predeterminedthreshold; identifying the corresponding candidate position detectionpatterns based on the determined centers of the candidate positiondetection patterns; and determining, from the identified candidateposition detection patterns, patterns that satisfy a QR code imagepositioning rule, and using the determined patterns as positiondetection patterns of the QR code image.

An implementation of the present application further provides a QR codepositioning method, including: determining, from a QR code image thatincludes first-type pixels and second-type pixels, centers of candidateposition detection patterns in the QR code image based on apredetermined pixel detection rule, where the pixel detection ruleincludes that a consecutive arrangement ratio of a first-type pixel, asecond-type pixel, and a first-type pixel satisfies a predeterminedratio identifying the corresponding candidate position detectionpatterns based on the determined centers of the candidate positiondetection patterns; and determining, from the identified candidateposition detection patterns, patterns that satisfy a QR code imagepositioning rule, and using the determined patterns as positiondetection patterns of the QR code image.

An implementation of the present application further provides a QR codepositioning apparatus, including: a position determining module,configured to determine, from a QR code image that includes first-typepixels and second-type pixels, centers of candidate position detectionpatterns in the QR code image based on a predetermined row pixeldetection rule and a predetermined column pixel detection rule, wherethe row pixel detection rule includes that a consecutive arrangementratio of a first-type pixel, a second-type pixel, and a first-type pixelsatisfies a first predetermined ratio, and the column pixel detectionrule includes that a consecutive arrangement ratio of a first-typepixel, a second-type pixel, and a first-type pixel satisfies a secondpredetermined ratio; an identification module, configured to identifythe corresponding candidate position detection patterns based on thedetermined centers of the candidate position detection patterns; and apattern determining module, configured to determine, from the identifiedcandidate position detection patterns, patterns that satisfy a QR codeimage positioning rule, and use the determined patterns as positiondetection patterns of the QR code image.

An implementation of the present application further provides a QR codepositioning apparatus, including: a position determining module,configured to determine, from a QR code image that includes first-typepixels and second-type pixels, centers of candidate position detectionpatterns in the QR code image based on a predetermined row pixeldetection rule and a predetermined column pixel detection rule, wherethe row pixel detection rule includes that a quantity of consecutivelyarranged first-type pixels or a quantity of consecutively arrangedsecond-type pixels reaches a first predetermined threshold, and thecolumn pixel detection rule includes that a quantity of consecutivelyarranged first-type pixels or a quantity of consecutively arrangedsecond-type pixels reaches a second predetermined threshold; anidentification module, configured to identify the correspondingcandidate position detection patterns based on the determined centers ofthe candidate position detection patterns; and a pattern determiningmodule, configured to determine, from the identified candidate positiondetection patterns, patterns that satisfy a QR code image positioningrule, and use the determined patterns as position detection patterns ofthe QR code image.

An implementation of the present application further provides a QR codepositioning apparatus, including: a position determining module,configured to determine, from a QR code image that includes first-typepixels and second-type pixels, centers of candidate position detectionpatterns in the QR code image based on a predetermined pixel detectionrule, where the pixel detection rule includes that a consecutivearrangement ratio of a first-type pixel, a second-type pixel, and afirst-type pixel satisfies a predetermined ratio; an identificationmodule, configured to identify the corresponding candidate positiondetection patterns based on the determined centers of the candidateposition detection patterns; and a pattern determining module,configured to determine, from the identified candidate positiondetection patterns, patterns that satisfy a QR code image positioningrule, and use the determined patterns as position detection patterns ofthe QR code image.

An implementation of the present application further provides a QR codepositioning device, including: a processor; and a memory arranged tostore computer executable instructions, where when the executableinstructions are being executed, the processor is enabled to: determine,from a QR code image that includes first-type pixels and second-typepixels, centers of candidate position detection patterns in the QR codeimage based on a predetermined row pixel detection rule and apredetermined column pixel detection rule, where the row pixel detectionrule includes that a consecutive arrangement ratio of a first-typepixel, a second-type pixel, and a first-type pixel satisfies a firstpredetermined ratio, and the column pixel detection rule includes that aconsecutive arrangement ratio of a first-type pixel, a second-typepixel, and a first-type pixel satisfies a second predetermined ratio;identify the corresponding candidate position detection patterns basedon the determined centers of the candidate position detection patterns;and determine, from the identified candidate position detectionpatterns, patterns that satisfy a QR code image positioning rule, anduse the determined patterns as position detection patterns of the QRcode image.

An implementation of the present application further provides a QR codepositioning device, including: a processor; and a memory arranged tostore computer executable instructions, where when the executableinstructions are being executed, the processor is enabled to: determine,from a QR code image that includes first-type pixels and second-typepixels, centers of candidate position detection patterns in the QR codeimage based on a predetermined row pixel detection rule and apredetermined column pixel detection rule, where the row pixel detectionrule includes that a quantity of consecutively arranged first-typepixels or a quantity of consecutively arranged second-type pixelsreaches a first predetermined threshold, and the column pixel detectionrule includes that a quantity of consecutively arranged first-typepixels or a quantity of consecutively arranged second-type pixelsreaches a second predetermined threshold; identify the correspondingcandidate position detection patterns based on the determined centers ofthe candidate position detection patterns; and determine, from theidentified candidate position detection patterns, patterns that satisfya QR code image positioning rule, and use the determined patterns asposition detection patterns of the QR code image.

An implementation of the present application further provides a QR codepositioning device, including: a processor; and a memory arranged tostore computer executable instructions, where when the executableinstructions are being executed, the processor is enabled to: determine,from a QR code image that includes first-type pixels and second-typepixels, centers of candidate position detection patterns in the QR codeimage based on a predetermined pixel detection rule, where the pixeldetection rule includes that a consecutive arrangement ratio of afirst-type pixel, a second-type pixel, and a first-type pixel satisfiesa predetermined ratio; identify the corresponding candidate positiondetection patterns based on the determined centers of the candidateposition detection patterns; and determine, from the identifiedcandidate position detection patterns, patterns that satisfy a QR codeimage positioning rule, and use the determined patterns as positiondetection patterns of the QR code image.

An implementation of the present application further provides a storagemedium, configured to store computer executable instructions, where whenthe executable instructions are being executed, the following proceduresare implemented: determining, from a QR code image that includesfirst-type pixels and second-type pixels, centers of candidate positiondetection patterns in the QR code image based on a predetermined rowpixel detection rule and a predetermined column pixel detection rule,where the row pixel detection rule includes that a consecutivearrangement ratio of a first-type pixel, a second-type pixel, and afirst-type pixel satisfies a first predetermined ratio, and the columnpixel detection rule includes that a consecutive arrangement ratio of afirst-type pixel, a second-type pixel, and a first-type pixel satisfiesa second predetermined ratio; identifying the corresponding candidateposition detection patterns based on the determined centers of thecandidate position detection patterns; and determining, from theidentified candidate position detection patterns, patterns that satisfya QR code image positioning rule, and using the determined patterns asposition detection patterns of the QR code image.

An implementation of the present application further provides a storagemedium, configured to store computer executable instructions, where whenthe executable instructions are being executed, the following proceduresare implemented: determining, from a QR code image that includesfirst-type pixels and second-type pixels, centers of candidate positiondetection patterns in the QR code image based on a predetermined rowpixel detection rule and a predetermined column pixel detection rule,where the row pixel detection rule includes that a quantity ofconsecutively arranged first-type pixels or a quantity of consecutivelyarranged second-type pixels reaches a first predetermined threshold, andthe column pixel detection rule includes that a quantity ofconsecutively arranged first-type pixels or a quantity of consecutivelyarranged second-type pixels reaches a second predetermined threshold;identifying the corresponding candidate position detection patternsbased on the determined centers of the candidate position detectionpatterns; and determining, from the identified candidate positiondetection patterns, patterns that satisfy a QR code image positioningrule, and using the determined patterns as position detection patternsof the QR code image.

An implementation of the present application further provides a storagemedium, configured to store computer executable instructions, where whenthe executable instructions are being executed, the following proceduresare implemented: determining, from a QR code image that includesfirst-type pixels and second-type pixels, centers of candidate positiondetection patterns in the QR code image based on a predetermined pixeldetection rule, where the pixel detection rule includes that aconsecutive arrangement ratio of a first-type pixel, a second-typepixel, and a first-type pixel satisfies a predetermined ratio;identifying the corresponding candidate position detection patternsbased on the determined centers of the candidate position detectionpatterns; and determining, from the identified candidate positiondetection patterns, patterns that satisfy a QR code image positioningrule, and using the determined patterns as position detection patternsof the QR code image.

According to the QR code positioning method and apparatus in theimplementations of the present application, the centers of the candidateposition detection patterns in the QR code image are determined based onthe arrangement ratio of a first-type pixel, a second-type pixel, and afirst-type pixel or based on the quantity of consecutively arrangedfirst-type pixels or the quantity of consecutively arranged second-typepixels, which has certain fault tolerance. As such, the candidateposition detection patterns can be identified even if the positiondetection patterns of the QR code are stained or are weak in brightness,thereby improving identification validity of the candidate positiondetection patterns. In addition, after the candidate position detectionpatterns are identified by using the previous method, the positiondetection patterns of the QR code are determined from the identifiedcandidate position detection patterns, so that accuracy is relativelyhigh.

BRIEF DESCRIPTION OF DRAWINGS

To describe the technical solutions in the implementations of thepresent application or in the existing technology more clearly, thefollowing briefly describes the accompanying drawings required fordescribing the implementations or the existing technology. Apparently,the accompanying drawings in the following description merely show someimplementations of the present application, and a person of ordinaryskill in the art can still derive other drawings from these accompanyingdrawings without creative efforts.

FIG. 1 is a first schematic flowchart illustrating a QR code positioningmethod, according to an implementation of the present application;

FIG. 2 is a schematic diagram illustrating a position detection patternof a QR code, according to an implementation of the present application;

FIG. 3 is a schematic diagram illustrating a coordinate systemestablished on a QR code, according to an implementation of the presentapplication;

FIG. 4 is a schematic diagram illustrating a first pixel arrangement anda second pixel arrangement that are determined on a position detectionpattern of a QR code, according to an implementation of the presentapplication;

FIG. 5 is a second schematic flowchart illustrating a QR codepositioning method, according to an implementation of the presentapplication;

FIG. 6 is a third schematic flowchart illustrating a QR code positioningmethod, according to an implementation of the present application;

FIG. 7 is a fourth schematic flowchart illustrating a QR codepositioning method, according to an implementation of the presentapplication;

FIG. 8 is a fifth schematic flowchart illustrating a QR code positioningmethod, according to an implementation of the present application;

FIG. 9 is a schematic diagram illustrating module composition of a QRcode positioning apparatus, according to an implementation of thepresent application; and

FIG. 10 is a schematic structural diagram illustrating a QR codepositioning device, according to an implementation of the presentapplication.

DESCRIPTION OF IMPLEMENTATIONS

To make a person skilled in the art understand the technical solutionsin the present application better, the following clearly describes thetechnical solutions in the implementations of the present applicationwith reference to the accompanying drawings in the implementations ofthe present application. Apparently, the described implementations aremerely some but not all of the implementations of the presentapplication. All other implementations obtained by a person of ordinaryskill in the art based on the implementations of the present applicationwithout creative efforts shall fall within the protection scope of thepresent application.

The implementations of the present application provide a QR codepositioning method and apparatus, and the method can be applied to ascenario in which a QR code is used for payment, identityauthentication, etc. The QR code can be a QR code used by anyapplication programs, such as ALIPAY or WeChat.

Generally, when a QR code is applied, the QR code needs to be identifiedto obtain information stored in the QR code. The QR code identificationincludes at least QR code positioning and QR code decoding. That is, theQR code positioning is one step of the QR code identification.

The method provided in the implementations of the present applicationcan be executed by a terminal, for example, a mobile phone, a computer,a tablet computer, or a QR code scanning device. In this case, after theterminal obtains a QR code image, the terminal directly executes themethod provided in the implementations of the present application on theobtained QR code image. Certainly, the method provided in theimplementations of the present application can be executed by a server.In this case, first, a terminal obtains a QR code image throughscanning; and then, the server obtains the QR code image from theterminal, and the server executes the method provided in theimplementations of the present application on the obtained QR codeimage.

FIG. 1 is a first schematic flowchart illustrating a QR code positioningmethod, according to an implementation of the present application. Asshown in FIG. 1, the method includes at least the following steps.

Step S102: Determine, from a QR code image that includes first-typepixels and second-type pixels, centers of candidate position detectionpatterns in the QR code image based on a predetermined row pixeldetection rule and a predetermined column pixel detection rule, wherethe row pixel detection rule includes that a consecutive arrangementratio of a first-type pixel, a second-type pixel, and a first-type pixelsatisfies a first predetermined ratio, and the column pixel detectionrule includes that a consecutive arrangement ratio of a first-typepixel, a second-type pixel, and a first-type pixel satisfies a secondpredetermined ratio.

The first-type pixel and the second-type pixel are pixels of differentcolors. For example, when the QR code is a black-and-white QR code, thefirst-type pixel can be a black pixel, and the second-type pixel can bea white pixel. When the QR code is a blue-and-white QR code, thefirst-type pixel can be a blue pixel, and the second-type pixel can be awhite pixel.

In addition, in a specific implementation, to facilitate subsequentprocessing, after an original QR code image is obtained, binarizationprocessing is performed on the original QR code image to obtain abinarized image of the QR code image. In this case, pixels in the QRcode image are in only two colors: black and white. Therefore, thefirst-type pixel can be a black pixel, and the second-type pixel can bea white pixel.

Generally, three position detection patterns are set in each QR code,and the three position detection patterns are located at any three offour corners of the QR code. The position detection pattern is generallya rectangular pattern, and can be a square with four equal sides, or canbe a rectangle. It can be considered that each position detectionpattern includes three concentric rectangles. FIG. 2 is a possibleschematic diagram illustrating a position detection pattern of a QRcode, according to an implementation of the present application. Theposition detection pattern in FIG. 2 includes three concentric squares.The three squares are a 7×7 black module, a 5×5 white module, and a 3×3black module. That is, a first-type pixel is a black pixel, asecond-type pixel is a white pixel, and a modular width ratio of theposition detection pattern is 1:1:3:1:1. In FIG. 2, the outermost blackrectangular area of the position detection pattern is denoted as a firstarea, the middle black rectangular area of the position detectionpattern is denoted as a third area, and a white area between the firstarea and the second area is denoted as a second area.

The first predetermined ratio is 1:n:1, and n is greater than 1. Thesecond predetermined ratio is 1:m:1, and m is greater than 1. Values ofm and n can be the same or can be different, and specific values of mand n can be determined based on an actual application scenario. Forexample, for the existing 1:1:3:1:1 position detection pattern, bothvalues of m and n can be 5, that is, the first predetermined ratio canbe 1:5:1, and the second predetermined ratio can be 1:5:1.

In this implementation of the present application, the determiningcenters of candidate position detection patterns in the QR code imageincludes the following steps (a₁) and (a₂): (a₁) determining, from rowpixels, first pixel arrangements in which consecutive arrangement ratiosof a first-type pixel, a second-type pixel, and a first-type pixelsatisfy the first predetermined ratio; and determining, from columnpixels, second pixel arrangements in which consecutive arrangementratios of a first-type pixel, a second-type pixel, and a first-typepixel satisfy the second predetermined ratio; and (a₂) determining thecenters of the candidate position detection patterns based on centers ofthe first pixel arrangements and centers of the second pixelarrangements.

The consecutive arrangement ratio of the first-type pixel, thesecond-type pixel, and the first-type pixel satisfies a firstpredetermined ratio refers to: first-type pixel:second-typepixel:first-type pixel=1:n:1. The consecutive arrangement ratio of thefirst-type pixel, the second-type pixel, and the first-type pixelsatisfies a second predetermined ratio refers to: first-typepixel:second-type pixel:first-type pixel=1:m:1. Specifically, the pixelarrangement ratio here can be a pixel quantity arrangement ratio.

In this implementation of the present application, the first pixelarrangement that satisfies the first predetermined ratio is a row ofpixels that passes through only the first area and the second area inFIG. 2, and the second pixel arrangement that satisfies the secondpredetermined ratio is a column of pixels that passes through only thefirst area and the second area in FIG. 2.

In practice, because the scanned QR code image may be deformed,incomplete, stained, etc., the consecutive arrangement ratio of afirst-type pixel, a second-type pixel, and a first-type pixel in thefirst pixel arrangement in the position detection pattern in the QR codeimage cannot strictly satisfy the first predetermined ratio, and theconsecutive arrangement ratio of a first-type pixel, a second-typepixel, and a first-type pixel in the second pixel arrangement in theposition detection pattern in the QR code image cannot strictly satisfythe second predetermined ratio. Therefore, in step (a₁), provided that aconsecutive arrangement ratio of a first-type pixel, a second-typepixel, and a first-type pixel falls within an error range of the firstpredetermined ratio or the second predetermined ratio, it can beconsidered that the consecutive arrangement ratio of a first-type pixel,a second-type pixel, and a first-type pixel satisfies the firstpredetermined ratio or the second predetermined ratio.

In step (a₂), coordinates of the centers of the candidate positiondetection patterns can be determined based on the centers of the firstpixel arrangements and the centers of the second pixel arrangements, andthen the centers of the candidate position detection pattern can bedetermined.

In a specific implementation, the upper left corner of the QR code isused as a coordinate origin O, a horizontal line that passes through thecoordinate origin is used as a horizontal axis (X axis), and a verticalline that passes through the coordinate origin is used as a verticalaxis (Y axis), to establish an OXY coordinate system, as shown in FIG.3. Specifically, the coordinates of the centers of the candidateposition detection patterns can be determined by using at least thefollowing three methods (b₁), (b₂), and (b₃):

(b1) A scanning line is drawn in the X direction in the QR code image,the QR code image is scanned in the Y direction by using the scanningline, and a first pixel arrangement is determined at a firstpredetermined position in each candidate position detection pattern.Then, a scanning line is drawn in the Y direction in the QR code image,the QR code image is scanned in the X direction by using the scanningline, and second pixel arrangements are separately determined at asecond predetermined position and a third predetermined position in eachcandidate position detection pattern. As shown in FIG. 4, the firstpixel arrangement at the first predetermined position is denoted as P₁,a second pixel arrangement at the second predetermined position isdenoted as P₂, and a second pixel arrangement at the third predeterminedposition is denoted as P₃. A distance from the second pixel arrangementP₂ to the left edge of the candidate position detection pattern isdenoted as a first distance, and distance from the second pixelarrangement P₃ to the right edge of the candidate position detectionpattern is denoted as a second distance. In a specific implementation,for ease of calculation, positions of the second pixel arrangement P₂and the second pixel arrangement P₃ are enabled to exactly satisfy acondition that the first distance is equal to the second distance. Anaverage value of positions of the second pixel arrangement P₂ and thesecond pixel arrangement P₃ in a horizontal direction is calculated,where the average value is a center of the first pixel arrangement P₁,and a horizontal coordinate of the center is denoted as a horizontalcoordinate of a center of the candidate position detection pattern.

In addition, in this implementation of the present application, theposition detection pattern in the QR code is evenly divided intomultiple rectangular modules. The rectangular module can be a squaremodule. A length-to-width ratio of the rectangular module can be setbased on an actual application scenario.

A width of each rectangular module can be calculated by calculating aratio of a width of the candidate position detection pattern and aquantity of rectangular modules in the width direction. Then, a centerof the second pixel arrangement is determined based on a position of thefirst pixel arrangement P₁ in the vertical direction and a quantity ofrectangular modules between the first pixel arrangement P₁ and thecenter in the vertical direction, and a vertical coordinate of thecenter of the second pixel arrangement is a vertical coordinate of thecenter of the candidate position detection pattern.

The first predetermined position can be any position that enables thefirst pixel arrangement to satisfy the first predetermined ratio, andthe second predetermined position and the third predetermined positioncan also be any position that enables the second pixel arrangementsatisfies the second predetermined ratio. In some implementations, forease of calculation, the first predetermined position, the secondpredetermined position, and the third predetermined position can be allset at an entire rectangular module.

(b₂) In this case, a method for determining the horizontal coordinate ofthe center of the candidate position detection pattern is the same asthe method for determining the horizontal coordinate in (b₁), anddetails are omitted here.

In addition, in this case, the vertical coordinate of the center of thecandidate position detection pattern is determined by using a method thesame as the method for determining the horizontal coordinate. A specificprocess is as follows: A scanning line is drawn in the X direction inthe QR code image, the QR code image is scanned in the Y direction byusing the scanning line, a first pixel distribution P₁ is determined ata first predetermined position, and a first pixel arrangement P₄ isdetermined at a fourth predetermined position. The vertical coordinateof the center of the candidate position detection pattern is determinedbased on the first pixel arrangement P₁ and the first pixel arrangementP₄. A specific process is similar to the previous process of determiningthe horizontal coordinate, and details are omitted here.

(b₃) A scanning line is drawn in the X direction in the QR code image,the QR code image is scanned in the Y direction by using the scanningline, and a first pixel arrangement P₁ is determined at a firstpredetermined position. A scanning line is drawn in the Y direction inthe QR code image, the QR code image is scanned in the X direction byusing the scanning line, and a second pixel arrangement P₂ is determinedat a second predetermined position. A center of the first pixelarrangement P₁ is determined based on distance between the first pixeland the last pixel of the first pixel arrangement P₁, and a center ofthe second pixel arrangement P₂ is determined by using the same method.The horizontal coordinate of the center of the candidate positiondetection pattern is determined based on the center of the first pixelarrangement P₁, and the vertical coordinate of the center of thecandidate position detection pattern is determined based on the centerof the second pixel arrangement P₂.

In this implementation of the present application, the first pixelarrangement is a row of pixels in the candidate position detectionpattern, and the second pixel arrangement is a column of pixels in thecandidate position detection pattern.

In this implementation of the present application, the centers of thecandidate position detection patterns in the QR code image aredetermined based on only the consecutive arrangement ratio of afirst-type pixel, a second-type pixel, and a first-type pixel, so thatQR code recognition validity is improved.

Step S104: Identify the corresponding candidate position detectionpatterns based on the determined centers of the candidate positiondetection patterns.

In this implementation of the present application, after the centers ofthe candidate position detection patterns are determined, patterns thatthe centers are located in are determined as the candidate positiondetection patterns of the QR code.

Step S106: Determine, from the identified candidate position detectionpatterns, patterns that satisfy a QR code image positioning rule, anduse the determined patterns as position detection patterns of the QRcode image.

In this implementation of the present application, the candidateposition detection patterns in the QR code image can be identified byusing step S102 and step S104. However, another pattern may exist in thecandidate position detection patterns that are identified by using onlythe two steps. Therefore, to improve position detection patternrecognition accuracy, further selection needs to be performed on theidentified candidate position detection patterns, and the patterns thatsatisfy the QR code image positioning rule are determined from selectedcandidate position detection patterns, which is specifically implementedby using the following steps (1) and (2): (1) determining, from theidentified candidate position detection patterns, candidate positiondetection patterns that satisfy at least one of a first selectioncondition and a second selection condition, where the first selectioncondition includes that at least one of a quantity of first-type pixelsand a quantity of second-type pixels within a predetermined areaadjacent to the center satisfies a predetermined threshold range, andthe second selection condition includes that a consecutive arrangementratio of a first-type pixel, a second-type pixel, a first-type pixel, asecond-type pixel, and a first-type pixel in a third pixel arrangementthat passes through the center satisfies a third predetermined ratio;and (2) determining, from the candidate position detection patterns thatsatisfy at least one of the first selection condition and the secondselection condition, the patterns that satisfy the QR code positioningrule.

Specifically, the determining, from the identified candidate positiondetection patterns, patterns that satisfy a QR code image positioningrule includes the following three cases:

Case 1: determining, from the identified candidate position detectionpatterns, candidate position detection patterns that satisfy the firstselection condition, and determining, from the candidate positiondetection patterns that satisfy the first selection condition, thepatterns that satisfy the QR code positioning rule.

Case 2: determining, from the identified candidate position detectionpatterns, candidate position detection patterns that satisfy the secondselection condition, and determining, from the candidate positiondetection patterns that satisfy the second selection condition, thepatterns that satisfy the QR code positioning rule.

Case 3: determining, from the identified candidate position detectionpatterns, candidate position detection patterns that satisfy the firstselection condition and the second selection condition, and determining,from the candidate position detection patterns that satisfy the firstselection condition and the second selection condition, the patternsthat satisfy the QR code positioning rule.

In case 3, a specific implementation can be: first determining, from theidentified candidate position detection patterns, candidate positiondetection patterns that satisfy the first selection condition, and thenselecting, from the candidate position detection patterns that satisfythe first selection condition, candidate position detection patternsthat satisfy the second selection condition; and determining, from thecandidate position detection patterns that satisfy the second selectioncondition, the patterns that satisfy the QR code positioning rule.

Certainly, candidate position detection patterns that satisfy the secondselection condition can be first selected, and then candidate positiondetection patterns that satisfy the first selection condition can beselected from the candidate position detection patterns that satisfy thesecond selection condition.

Specifically, in this implementation of the present application, aprocess of using the first selection condition for selection is asfollows: A pixel at the center of the candidate position detectionpattern is used as a center to select a predetermined quantity of pixelsaround the pixel at the center. For example, nine pixels or five pixelsincluding the pixel at the center are selected. Then, a quantity offirst-type pixels and a quantity of second-type pixels in the selectedpredetermined quantity of pixels are determined, and selection isperformed based on the quantity of first-type pixels and the quantity ofsecond-type pixels. For example, if a third area that the center islocated in is a black pixel area, the first-type pixel is a black pixel,and the second-type pixel is a white pixel. In a normal case, all pixelsin the third area are first-type pixels, or there might be several whitepixels in the third area due to impact of salt and pepper noise.Therefore, the quantity of second-type pixels in the selectedpredetermined quantity of pixels is determined, and when a ratio of thequantity of second-type pixels and the predetermined quantity is greaterthan a predetermined ratio, the candidate position detection pattern isnot selected.

Specifically, the third pixel arrangement can be any pixel arrangementincluding the pixel at the center. For example, the third pixelarrangement can be a diagonal of the candidate position detectionpattern; or can be an oblique line that includes the pixel at thecenter, where a value of an angle between the oblique line and ahorizontal line is 30°.

In a 1:1:3:1:1 position detection pattern, the third predetermined ratiois 1:1:3:1:1.

FIG. 5 is a second schematic flowchart illustrating a QR codepositioning method, according to an implementation of the presentapplication. As shown in FIG. 5, the method includes the followingsteps.

Step S202: Determine, from row pixels in a QR code image that includesfirst-type pixels and second-type pixels, first pixel arrangements inwhich consecutive arrangement ratios of a first-type pixel, asecond-type pixel, and a first-type pixel satisfy a first predeterminedratio, and determine, from column pixels in the QR code image thatincludes the first-type pixels and the second-type pixels, second pixelarrangements in which consecutive arrangement ratios of a first-typepixel, a second-type pixel, and a first-type pixel satisfy a secondpredetermined ratio.

Step S204: Determine centers of candidate position detection patternsbased on centers of the first pixel arrangements and centers of thesecond pixel arrangements.

Step S206: Identify the corresponding candidate position detectionpatterns based on the determined centers of the candidate positiondetection patterns.

Step S208: Determine, from the identified candidate position detectionpatterns, candidate position detection patterns that satisfy a firstselection condition.

Step S210: Determine, from the candidate position detection patternsthat satisfy the first selection condition, candidate position detectionpatterns that satisfy a second selection condition.

Step S212: Determine, from the candidate position detection patternsthat satisfy the second selection condition, patterns that satisfy a QRcode positioning rule.

Three position detection patterns in the QR code are located at anythree of four corners of the QR code. Therefore, the positioning rulecan include that the shortest two lines among the three lines thatconnect centers of the three position detection patterns areperpendicular with each other and are equal in length.

The center of the position detection pattern is a center of the positiondetection pattern.

Therefore, determining, from candidate position detection patterns thatsatisfy at least one of the first selection condition and the secondselection condition, the patterns that satisfy the QR code positioningrule includes: forming, from the candidate position detection patternsthat satisfy at least one of the first selection condition and thesecond selection condition, multiple groups of candidate positiondetection patterns by using each three candidate position detectionpatterns as one group; determining whether each group of candidateposition detection patterns satisfies the previous positioning rule; andusing at least one group of candidate position detection patterns thatsatisfy the positioning rule as the position detection patterns of theQR code image.

At least three candidate position detection patterns that satisfy atleast one of the first selection condition and the second selectioncondition are selected. In this implementation of the presentapplication, a quantity of selected candidate position detectionpatterns that satisfy at least one of the first selection condition andthe second selection condition is denoted as N, and S=C_(N) ³ groups ofcandidate position detection patterns can be formed from the N candidateposition detection patterns by using each three candidate positiondetection patterns as one group. For example, four candidate positiondetection patterns that satisfy at least one of the first selectioncondition and the second selection condition are selected and denoted asA₁, A₂, A₃, and A₄, and S=C₄ ³=4 groups of candidate position detectionpatterns can be formed by using each three candidate position detectionpatterns as one group and denoted as {A₁, A₂, A₃}, {A₁, A₃, A₄}, {A₁,A₂, A₄}, and {A₂, A₃, A₄}.

Specifically, connection lines of centers of each group of candidateposition detection patterns can form a triangle. When determiningwhether each group of candidate position detection patterns satisfiesthe positioning rule, it can be determined whether a value of an anglebetween two short sides in the triangle is 90° and whether the two shortsides are equal. Because the obtained QR code image may be deformed,etc., a value of an angle between two short sides in a triangle formedby centers of three position detection patterns is not necessarily 90°.Therefore, in practice, when determining whether each group of candidateposition detection patterns satisfies the positioning rule, if adifference between 90° and a value of an angle between two short sidesin a triangle formed by centers of each group of candidate positiondetection patterns falls within a predetermined range and if a lengthdifference between the two short sides falls within a predeterminederror range, it is determined that the group of candidate positiondetection patterns satisfies the positioning rule.

In addition to the previous method for determining the patterns thatsatisfy the QR code positioning rule, this implementation of the presentapplication further provides the following method, specificallyincluding: forming, from the candidate position detection patterns thatsatisfy at least one of the first selection condition and the secondselection condition, multiple groups of candidate position detectionpatterns by using each three candidate position detection patterns asone group; determining geometric parameters of a triangle formed byconnection lines of centers of three candidate position detectionpatterns in each group of candidate position detection patterns and astandard deviation of areas of the three candidate position detectionpatterns, where the geometric parameters include a value of an anglebetween two short connection lines in the triangle and a lengthdifference between the two short connection lines; and determining,based on the value of the angle, the length difference, and the standarddeviation, the patterns that satisfy the QR code positioning rule.

A specific process of determining the standard deviation of the areas ofthe three candidate position detection patterns is as follows: A lengthand a width of each module are determined based on a length and a widthof each candidate position detection pattern and a quantity of modulesin each candidate position detection pattern, and an area of each moduleis calculated. Then, an area of each candidate position detectionpattern is calculated based on the area of each module and the quantityof modules. Finally, the standard deviation of the areas of the threecandidate position detection patterns is calculated based on the areasof the three candidate position detection patterns and a standarddeviation equation.

Specifically, in this implementation of the present application, thedetermining, based on the value of the angle, the length difference, andthe standard deviation, the patterns that satisfy the QR codepositioning rule specifically includes the following steps: calculatinga score of each group of candidate position detection patterns based onthe value of the angle, the length difference, and the standarddeviation by using equation (1); and comparing the score of each groupof candidate position detection patterns with a predetermined score, anddetermining, based on a comparison result, the patterns that satisfy theQR code positioning rule, where

$\begin{matrix}{{f_{i} = \frac{1}{1 + e^{{ax}_{i} + {by}_{i} + {cz}_{i} + d}}}.} & (1)\end{matrix}$

In equation (1), a, b, c, and d are all constants, x_(i) represents avalue of an angle between two short connection lines in a triangleformed by connection lines of centers of an ith group of candidateposition detection patterns, y_(i) represents a length differencebetween the two short connection lines in the triangle formed by theconnection lines of the centers of the ith group of candidate positiondetection patterns, z_(i) represents a standard deviation of areas ofthree candidate position detection patterns in the ith group ofcandidate position detection patterns, and f_(i) represents a score ofthe ith group of candidate position detection patterns.

After the score of each group of candidate position detection patternsis determined, the score is compared with the predetermined score. In aspecific implementation, when the score is greater than or equal to thepredetermined score, it is determined that the group of candidateposition detection patterns satisfies the QR code positioning rule.

In this implementation of the present application, one or more groups ofposition detection patterns that satisfy the QR code positioning rulecan be determined.

Based on the methods in FIG. 1 to FIG. 5, an implementation of thepresent application further provides a QR code positioning method. FIG.6 is a third schematic flowchart illustrating a QR code positioningmethod, according to an implementation of the present application. Themethod can be executed by a terminal or a server. For the method shownin FIG. 6, a difference from the methods in FIG. 1 to FIG. 5 is mainlydescribed here. For the same parts, references can be made to theprevious descriptions in FIG. 1 to FIG. 5, and details are omitted here.As shown in FIG. 6, the method includes the following steps.

Step S602: Determine, from a QR code image that includes first-typepixels and second-type pixels, centers of candidate position detectionpatterns in the QR code image based on a predetermined row pixeldetection rule and a predetermined column pixel detection rule, wherethe row pixel detection rule includes that a quantity of consecutivelyarranged first-type pixels or a quantity of consecutively arrangedsecond-type pixels reaches a first predetermined threshold, and thecolumn pixel detection rule includes that a quantity of consecutivelyarranged first-type pixels or a quantity of consecutively arrangedsecond-type pixels reaches a second predetermined threshold.

Specifically, the row pixel detection rule can be that the quantity ofconsecutively arranged first-type pixels reaches the first predeterminedthreshold, and correspondingly, the column pixel detection rule can bethat the quantity of consecutively arranged first-type pixels reachesthe second predetermined threshold. Alternatively, the row pixeldetection rule can be that the quantity of consecutively arrangedsecond-type pixels reaches the first predetermined threshold, andcorrespondingly, the column pixel detection rule can be that thequantity of consecutively arranged second-type pixels reaches the secondpredetermined threshold.

The first predetermined threshold can be equal to the secondpredetermined threshold. In a specific application scenario, a positiondetection pattern in a QR code used by ALIPAY is a square, that is, thelength of the position detection pattern is equal to the width of theposition detection pattern. In this case, the first predeterminedthreshold is equal to the second predetermined threshold.

Pixel arrangements that satisfy the row pixel detection rule and thecolumn pixel detection rule are generally located in a first area of abinary detection pattern (as shown in FIG. 2).

Step S604: Identify the corresponding candidate position detectionpatterns based on the determined centers of the candidate positiondetection patterns.

Step S606: Determine, from the identified candidate position detectionpatterns, patterns that satisfy a QR code image positioning rule, anduse the determined patterns as position detection patterns of the QRcode image.

In a specific implementation, for example, a position detection patternin a black-and-white QR code used by ALIPAY is in a 1:1:3:1:1 mode, andthree concentric squares are a 7×7 black module, a 5×5 white module, anda 3×3 black module. In this case, the row pixel detection rule can bethat a quantity of consecutively arranged black pixels reaches aquantity of black pixels in the 7×7 black module, and the column pixeldetection rule can be that a quantity of consecutively arranged blackpixels reaches the quantity of black pixels in the 7×7 black module. Afirst pixel arrangement that satisfies the row pixel detection rule islocated in a first area of the position detection pattern, and a secondpixel arrangement that satisfies the column pixel detection rule islocated in the first area of the position detection pattern. As such,the candidate position detection patterns in the QR code can be quicklyidentified.

In this implementation of the present application, the centers of thecandidate position detection patterns in the QR code image aredetermined based on the arrangement ratio of a first-type pixel, asecond-type pixel, and a first-type pixel or based on the quantity ofconsecutively arranged first-type pixels or the quantity ofconsecutively arranged second-type pixels, which has certain faulttolerance. As such, the candidate position detection patterns can beidentified even if the position detection patterns of the QR code arestained or are weak in brightness, thereby improving identificationvalidity of the candidate position detection patterns. In addition,after the candidate position detection patterns are identified by usingthe previous method, the position detection patterns of the QR code aredetermined from the identified candidate position detection patterns, sothat accuracy is relatively high.

Based on the methods in FIG. 1 to FIG. 5, an implementation of thepresent application further provides a QR code positioning method. FIG.7 is a fourth schematic flowchart illustrating a QR code positioningmethod, according to an implementation of the present application. Themethod can be executed by a terminal or a server. For the method shownin FIG. 7, a difference from the methods in FIG. 1 to FIG. 5 is mainlydescribed here. For the same parts, references can be made to theprevious descriptions in FIG. 1 to FIG. 5, and details are omitted here.As shown in FIG. 7, the method includes the following steps.

Step S702: Determine, from a QR code image that includes first-typepixels and second-type pixels, centers of candidate position detectionpatterns in the QR code image based on a predetermined pixel detectionrule, where the pixel detection rule includes that a consecutivearrangement ratio of a first-type pixel, a second-type pixel, and afirst-type pixel satisfies a predetermined ratio.

The predetermined ratio can be 1:5:1 for a QR code used by ALIPAY at acurrent stage.

In this implementation of the present application, the first-type pixelis a foreground color pixel, and the second-type pixel is a backgroundcolor pixel. Specifically, the first-type pixel is a black pixel or ablue pixel, and the second-type pixel is a pixel whose color differencewith the first-type pixel exceeds a specified threshold. For example,the second-type pixel can be white.

Certainly, in addition to the black pixel and the blue pixel, thefirst-type pixel can be a pixel in another color.

Currently, QR codes used by ALIPAY include a black-and-white QR code, ablue-and-white QR code, etc. Therefore, in a specific implementation,the first-type pixel is a black pixel, and the second-type pixel is awhite pixel. In another implementation, the first-type pixel is a bluepixel, and the second-type pixel is a white pixel.

Step S704: Identify the corresponding candidate position detectionpatterns based on the determined centers of the candidate positiondetection patterns.

Step S706: Determine, from the identified candidate position detectionpatterns, patterns that satisfy a QR code image positioning rule, anduse the determined patterns as position detection patterns of the QRcode image.

A black-and-white QR code used by ALIPAY is used as an example. Aspecific QR code positioning method is now described with reference to aspecific application scenario. FIG. 8 is a fifth schematic flowchartillustrating a QR code positioning method, according to animplementation of the present application. The method can be executed bya terminal or a server. As shown in FIG. 8, the method includes thefollowing steps:

Step S802: Obtain an original QR code image scanned by using ALIPAY.

Step S804: Process the original QR code image to obtain a QR code imagethat includes black pixels and white pixels.

The processing the original QR code image can include denoising,binarization, etc.

Step S806: Determine, based on a predetermined pixel detection rule fromthe QR code image that includes the black pixels and the white pixels,row pixel arrangements in which consecutive arrangement ratios of ablack pixel, a white pixel, and a black pixel satisfy 1:5:1 in rowpixels, and column pixel arrangements in which consecutive arrangementratios of a black pixel, a white pixel, and a black pixel satisfy 1:5:1in column pixels.

Step S808: Determine centers of candidate position detection patternsbased on centers of the row pixel arrangements and centers of the columnpixel arrangements.

Step S810: Identify the corresponding candidate position detectionpatterns based on the determined centers of the candidate positiondetection patterns.

Step S812: Determine, from the identified candidate position detectionpatterns, candidate position detection patterns that satisfy a firstselection condition.

Step S814: Determine, from the candidate position detection patternsthat satisfy the first selection condition, candidate position detectionpatterns that satisfy a second selection condition.

Step S816: Form, from the candidate position detection patterns thatsatisfy the second selection condition, multiple groups of candidateposition detection patterns by using each three candidate positiondetection patterns as one group.

Step S818: Determine whether each group of candidate position detectionpatterns satisfies a QR code positioning rule; and if yes, perform stepS820.

Step S820: Use the group of candidate position detection patterns asposition detection patterns of the QR code image.

According to the previously described QR code positioning method, thecenters of the candidate position detection patterns in the QR codeimage are determined based on the arrangement ratio of a first-typepixel, a second-type pixel, and a first-type pixel, which has certainfault tolerance. As such, the candidate position detection patterns canbe identified even if the position detection patterns of the QR code arestained or are weak in brightness, thereby improving identificationvalidity of the candidate position detection patterns. In addition,after the candidate position detection patterns are identified by usingthe previous method, the position detection patterns of the QR code aredetermined from the identified candidate position detection patterns, sothat accuracy is relatively high.

Corresponding to the previous QR code positioning method, based on asame idea, an implementation of the present application further providesa QR code positioning apparatus, which can be applied to a terminal sideor a server side. FIG. 9 is a schematic diagram illustrating modulecomposition of a QR code positioning apparatus, according to animplementation of the present application. As shown in FIG. 9, theapparatus includes: position determining module 91, configured todetermine, from a QR code image that includes first-type pixels andsecond-type pixels, centers of candidate position detection patterns inthe QR code image based on a predetermined row pixel detection rule anda predetermined column pixel detection rule, where the row pixeldetection rule includes that a consecutive arrangement ratio of afirst-type pixel, a second-type pixel, and a first-type pixel satisfiesa first predetermined ratio, and the column pixel detection ruleincludes that a consecutive arrangement ratio of a first-type pixel, asecond-type pixel, and a first-type pixel satisfies a secondpredetermined ratio; identification module 92, configured to identifythe corresponding candidate position detection patterns based on thedetermined centers of the candidate position detection patterns; andpattern determining module 93, configured to determine, from theidentified candidate position detection patterns, patterns that satisfya QR code image positioning rule, and use the determined patterns asposition detection patterns of the QR code image.

Optionally, the first predetermined ratio is 1:n:1, and n is greaterthan 1; and the second predetermined ratio is 1:m:1, and m is greaterthan 1.

Optionally, position determining module 91 includes a pixel determiningunit and a position determining unit.

The pixel determining unit is configured to determine, from row pixels,first pixel arrangements in which consecutive arrangement ratios of afirst-type pixel, a second-type pixel, and a first-type pixel satisfythe first predetermined ratio; and determine, from column pixels, secondpixel arrangements in which consecutive arrangement ratios of afirst-type pixel, a second-type pixel, and a first-type pixel satisfythe second predetermined ratio. The position determining unit isconfigured to determine the centers of the candidate position detectionpatterns based on centers of the first pixel arrangements and centers ofthe second pixel arrangements.

Optionally, pattern determining module 93 includes a first patterndetermining unit and a second pattern determining unit.

The first pattern determining unit is configured to determine, from theidentified candidate position detection patterns, candidate positiondetection patterns that satisfy at least one of a first selectioncondition and a second selection condition, where the first selectioncondition includes that at least one of a quantity of first-type pixelsand a quantity of second-type pixels within a predetermined areaadjacent to the center satisfies a predetermined threshold range, andthe second selection condition includes that a consecutive arrangementratio of a first-type pixel, a second-type pixel, a first-type pixel, asecond-type pixel, and a first-type pixel in a third pixel arrangementthat passes through the center satisfies a third predetermined ratio.The second determining unit is configured to determine, from thecandidate position detection patterns that satisfy at least one of thefirst selection condition and the second selection condition, thepatterns that satisfy the QR code positioning rule.

Optionally, the positioning rule includes that the shortest two linesamong the three lines that connect centers of three position detectionpatterns are perpendicular with each other and are equal in length; andthe second pattern determining unit is specifically configured to form,from the candidate position detection patterns that satisfy at least oneof the first selection condition and the second selection condition,multiple groups of candidate position detection patterns by using eachthree candidate position detection patterns as one group; determinewhether each group of candidate position detection patterns satisfiesthe positioning rule; and use at least one group of candidate positiondetection patterns that satisfy the positioning rule as the positiondetection patterns of the QR code image.

Optionally, the second pattern determining unit is further specificallyconfigured to form, from the candidate position detection patterns thatsatisfy at least one of the first selection condition and the secondselection condition, multiple groups of candidate position detectionpatterns by using each three candidate position detection patterns asone group; determine geometric parameters of a triangle formed byconnection lines of centers of three candidate position detectionpatterns in each group of candidate position detection patterns and astandard deviation of areas of the three candidate position detectionpatterns, where the geometric parameters include a value of an anglebetween two short connection lines in the triangle and a lengthdifference between the two short connection lines; and determine, basedon the value of the angle, the length difference, and the standarddeviation, the patterns that satisfy the QR code positioning rule.

Optionally, the second pattern determining unit is specificallyconfigured to determine, by using the following process, the patternsthat satisfy the QR code positioning rule: calculating a score of eachgroup of candidate position detection patterns based on the value of theangle, the length difference, and the standard deviation by using thefollowing equation; and comparing the score of each group of candidateposition detection patterns with a predetermined score, and determining,based on a comparison result, the patterns that satisfy the QR codepositioning rule, where

${f_{i} = \frac{1}{1 + e^{{ax}_{i} + {by}_{i} + {cz}_{i} + d}}}.$

In the previous equation, a, b, c, and d are all constants, x_(i)represents a value of an angle between two short connection lines in atriangle formed by connection lines of centers of an ith group ofcandidate position detection patterns, y_(i) represents a lengthdifference between the two short connection lines in the triangle formedby the connection lines of the centers of the ith group of candidateposition detection patterns, z_(i) represents a standard deviation ofareas of three candidate position detection patterns in the ith group ofcandidate position detection patterns, and f_(i) represents a score ofthe ith group of candidate position detection patterns.

Corresponding to the previous QR code positioning method, based on asame idea, the modules in the QR code positioning apparatus shown inFIG. 9 further specifically have the following functions.

Position determining module 91 is further configured to determine, froma QR code image that includes first-type pixels and second-type pixels,centers of candidate position detection patterns in the QR code imagebased on a predetermined row pixel detection rule and a predeterminedcolumn pixel detection rule, where the row pixel detection rule includesthat a quantity of consecutively arranged first-type pixels or aquantity of consecutively arranged second-type pixels reaches a firstpredetermined threshold, and the column pixel detection rule includesthat a quantity of consecutively arranged first-type pixels or aquantity of consecutively arranged second-type pixels reaches a secondpredetermined threshold.

Identification module 92 is further configured to identify thecorresponding candidate position detection patterns based on thedetermined centers of the candidate position detection patterns.

Pattern determining module 93 is further configured to determine, fromthe identified candidate position detection patterns, patterns thatsatisfy a QR code image positioning rule, and use the determinedpatterns as position detection patterns of the QR code image.

Optionally, the first predetermined threshold is equal to the secondpredetermined threshold.

Corresponding to the previous QR code positioning method, based on asame idea, the modules in the QR code positioning apparatus shown inFIG. 9 further specifically have the following functions.

Position determining module 91 is further configured to determine, froma QR code image that includes first-type pixels and second-type pixels,centers of candidate position detection patterns in the QR code imagebased on a predetermined pixel detection rule, where the pixel detectionrule includes that a consecutive arrangement ratio of a first-typepixel, a second-type pixel, and a first-type pixel satisfies apredetermined ratio.

Identification module 92 is further configured to identify thecorresponding candidate position detection patterns based on thedetermined centers of the candidate position detection patterns.

Pattern determining module 93 is further configured to determine, fromthe identified candidate position detection patterns, patterns thatsatisfy a QR code image positioning rule, and use the determinedpatterns as position detection patterns of the QR code image.

Optionally, the predetermined ratio is 1:5:1.

Optionally, the first-type pixel is a black pixel or a blue pixel, andthe second-type pixel is a pixel whose color difference with thefirst-type pixel exceeds a specified threshold.

According to the QR code positioning apparatus in this implementation ofthe present application, the candidate position detection patterns inthe QR code are first determined based on the arrangement ratio of afirst-type pixel, a second-type pixel, and a first-type pixel or basedon the quantity of consecutively arranged first-type pixels or thequantity of consecutively arranged second-type pixels, which has certainfault tolerance. As such, the candidate position detection patterns canbe identified even if the position detection patterns of the QR code arestained or are weak in brightness, thereby improving identificationvalidity of the candidate position detection patterns. In addition,after the candidate position detection patterns are identified by usingthe previous method, the position detection patterns of the QR code aredetermined from the identified candidate position detection patterns, sothat accuracy is relatively high.

Further, based on the previous methods shown in FIG. 1 to FIG. 8, animplementation of the present application further provides a QR codepositioning device, as shown in FIG. 10.

The QR code positioning device can greatly vary with configurations orperformances, and can include one or more processors 901 and one or morememories 902. Memory 902 can store one or more application programs ordata. Memory 902 can be a temporary storage or a persistent storage. Theapplication program stored in memory 902 can include one or more modules(not shown in the figure), and each module can include a series ofcomputer executable instructions for the QR code positioning device.Further, processor 901 can be configured to communicate with memory 902,and execute a series of computer executable instructions in memory 902on the QR code positioning device. The QR code positioning device canfurther include one or more power supplies 903, one or more wired orwireless network interfaces 904, one or more input/output interfaces905, one or more keyboards 906, etc.

In a specific implementation, the QR code positioning device includes amemory and one or more programs. The one or more programs are stored inthe memory. The one or more programs can include one or more modules.Each module can include a series of computer executable instructions forthe QR code positioning device. One or more processors are configured toexecute the one or more programs, including the following computerexecutable instructions: determining, from a QR code image that includesfirst-type pixels and second-type pixels, centers of candidate positiondetection patterns in the QR code image based on a predetermined rowpixel detection rule and a predetermined column pixel detection rule,where the row pixel detection rule includes that a consecutivearrangement ratio of a first-type pixel, a second-type pixel, and afirst-type pixel satisfies a first predetermined ratio, and the columnpixel detection rule includes that a consecutive arrangement ratio of afirst-type pixel, a second-type pixel, and a first-type pixel satisfiesa second predetermined ratio; identifying the corresponding candidateposition detection patterns based on the determined centers of thecandidate position detection patterns; and determining, from theidentified candidate position detection patterns, patterns that satisfya QR code positioning rule, and using the determined patterns asposition detection patterns of the QR code.

Optionally, when the computer executable instructions are beingexecuted, the first predetermined ratio is 1:n:1, and n is greater than1; and the second predetermined ratio is 1:m:1, and m is greater than 1.

Optionally, when the computer executable instructions are beingexecuted, the determining centers of candidate position detectionpatterns in the QR code image includes: determining, from row pixels,first pixel arrangements in which consecutive arrangement ratios of afirst-type pixel, a second-type pixel, and a first-type pixel satisfythe first predetermined ratio; determining, from column pixels, secondpixel arrangements in which consecutive arrangement ratios of afirst-type pixel, a second-type pixel, and a first-type pixel satisfythe second predetermined ratio; and determining the centers of thecandidate position detection patterns based on centers of the firstpixel arrangements and centers of the second pixel arrangements.

Optionally, when the computer executable instructions are beingexecuted, the determining, from the identified candidate positiondetection patterns, patterns that satisfy a QR code image positioningrule includes: determining, from the identified candidate positiondetection patterns, candidate position detection patterns that satisfyat least one of a first selection condition and a second selectioncondition, where the first selection condition includes that at leastone of a quantity of first-type pixels and a quantity of second-typepixels within a predetermined area adjacent to the center satisfies apredetermined threshold range, and the second selection conditionincludes that a consecutive arrangement ratio of a first-type pixel, asecond-type pixel, a first-type pixel, a second-type pixel, and afirst-type pixel in a third pixel arrangement that passes through thecenter satisfies a third predetermined ratio; and determining, from thecandidate position detection patterns that satisfy at least one of thefirst selection condition and the second selection condition, thepatterns that satisfy the QR code positioning rule.

Optionally, the positioning rule includes that the shortest two linesamong the three lines that connect centers of three position detectionpatterns are perpendicular with each other and are equal in length. Whenthe computer executable instructions are being executed, thedetermining, from the candidate position detection patterns that satisfyat least one of the first selection condition and the second selectioncondition, the patterns that satisfy the QR code positioning ruleincludes: forming, from the candidate position detection patterns thatsatisfy at least one of the first selection condition and the secondselection condition, multiple groups of candidate position detectionpatterns by using each three candidate position detection patterns asone group; determining whether each group of candidate positiondetection patterns satisfies the positioning rule; and using at leastone group of candidate position detection patterns that satisfy thepositioning rule as the position detection patterns of the QR codeimage.

Optionally, when the computer executable instructions are beingexecuted, the determining, from the candidate position detectionpatterns that satisfy at least one of the first selection condition andthe second selection condition, the patterns that satisfy the QR codepositioning rule includes: forming, from the candidate positiondetection patterns that satisfy at least one of the first selectioncondition and the second selection condition, multiple groups ofcandidate position detection patterns by using each three candidateposition detection patterns as one group; determining geometricparameters of a triangle formed by connection lines of centers of threecandidate position detection patterns in each group of candidateposition detection patterns and a standard deviation of areas of thethree candidate position detection patterns, where the geometricparameters include a value of an angle between two short connectionlines in the triangle and a length difference between the two shortconnection lines; and determining, based on the value of the angle, thelength difference, and the standard deviation, the patterns that satisfythe QR code positioning rule.

Optionally, when the computer executable instructions are beingexecuted, the determining, based on the value of the angle, the lengthdifference, and the standard deviation, the patterns that satisfy the QRcode positioning rule includes: calculating a score of each group ofcandidate position detection patterns based on the value of the angle,the length difference, and the standard deviation by using the followingequation; and comparing the score of each group of candidate positiondetection patterns with a predetermined score, and determining, based ona comparison result, the patterns that satisfy the QR code positioningrule, where

${f_{i} = \frac{1}{1 + e^{{ax}_{i} + {by}_{i} + {cz}_{i} + d}}}.$

In the previous equation, a, b, c, and d are all constants, x_(i)represents a value of an angle between two short connection lines in atriangle formed by connection lines of centers of an ith group ofcandidate position detection patterns, y_(i) represents a lengthdifference between the two short connection lines in the triangle formedby the connection lines of the centers of the ith group of candidateposition detection patterns, z_(i) represents a standard deviation ofareas of three candidate position detection patterns in the ith group ofcandidate position detection patterns, and f_(i) represents a score ofthe ith group of candidate position detection patterns.

In a specific implementation, the QR code positioning device includes amemory and one or more programs. The one or more programs are stored inthe memory. The one or more programs can include one or more modules.Each module can include a series of computer executable instructions forthe QR code positioning device. One or more processors are configured toexecute the one or more programs, including the following computerexecutable instructions: determining, from a QR code image that includesfirst-type pixels and second-type pixels, centers of candidate positiondetection patterns in the QR code image based on a predetermined rowpixel detection rule and a predetermined column pixel detection rule,where the row pixel detection rule includes that a quantity ofconsecutively arranged first-type pixels or a quantity of consecutivelyarranged second-type pixels reaches a first predetermined threshold, andthe column pixel detection rule includes that a quantity ofconsecutively arranged first-type pixels or a quantity of consecutivelyarranged second-type pixels reaches a second predetermined threshold;identifying the corresponding candidate position detection patternsbased on the determined centers of the candidate position detectionpatterns; and determining, from the identified candidate positiondetection patterns, patterns that satisfy a QR code image positioningrule, and using the determined patterns as position detection patternsof the QR code image.

Optionally, when the computer executable instructions are beingexecuted, the first predetermined threshold is equal to the secondpredetermined threshold.

In a specific implementation, the QR code positioning device includes amemory and one or more programs. The one or more programs are stored inthe memory. The one or more programs can include one or more modules.Each module can include a series of computer executable instructions forthe QR code positioning device. One or more processors are configured toexecute the one or more programs, including the following computerexecutable instructions: determining, from a QR code image that includesfirst-type pixels and second-type pixels, centers of candidate positiondetection patterns in the QR code image based on a predetermined pixeldetection rule, where the pixel detection rule includes that aconsecutive arrangement ratio of a first-type pixel, a second-typepixel, and a first-type pixel satisfies a predetermined ratio;identifying the corresponding candidate position detection patternsbased on the determined centers of the candidate position detectionpatterns; and determining, from the identified candidate positiondetection patterns, patterns that satisfy a QR code image positioningrule, and using the determined patterns as position detection patternsof the QR code image.

Optionally, when the computer executable instructions are beingexecuted, the predetermined ratio is 1:5:1.

Optionally, when the computer executable instructions are beingexecuted, the first-type pixel is a black pixel or a blue pixel, and thesecond-type pixel is a pixel whose color difference with the first-typepixel exceeds a specified threshold.

In this implementation of the present application, after the executableinstructions stored in the storage medium are executed, the candidateposition detection patterns in the QR code are first determined based onthe arrangement ratio of a first-type pixel, a second-type pixel, and afirst-type pixel or based on the quantity of consecutively arrangedfirst-type pixels or the quantity of consecutively arranged second-typepixels, which has certain fault tolerance. As such, the candidateposition detection patterns can be identified even if the positiondetection patterns of the QR code are stained or are weak in brightness,thereby improving identification validity of the candidate positiondetection patterns. In addition, after the candidate position detectionpatterns are identified by using the previous method, the positiondetection patterns of the QR code are determined from the identifiedcandidate position detection patterns, so that accuracy is relativelyhigh.

Further, an implementation of the present application further provides astorage medium, configured to store computer executable instructions. Ina specific implementation, the storage medium can be a USB flash drive,an optical disc, a hard disk, etc. When the computer executableinstructions stored in the storage medium are being executed by aprocessor, the following procedures can be implemented: determining,from a QR code image that includes first-type pixels and second-typepixels, centers of candidate position detection patterns in the QR codeimage based on a predetermined row pixel detection rule and apredetermined column pixel detection rule, where the row pixel detectionrule includes that a consecutive arrangement ratio of a first-typepixel, a second-type pixel, and a first-type pixel satisfies a firstpredetermined ratio, and the column pixel detection rule includes that aconsecutive arrangement ratio of a first-type pixel, a second-typepixel, and a first-type pixel satisfies a second predetermined ratio;identifying the corresponding candidate position detection patternsbased on the determined centers of the candidate position detectionpatterns; and determining, from the identified candidate positiondetection patterns, patterns that satisfy a QR code positioning rule,and using the determined patterns as position detection patterns of theQR code.

Optionally, when the computer executable instructions stored in thestorage medium are being executed by the processor, the firstpredetermined ratio is 1:n:1, and n is greater than 1; and the secondpredetermined ratio is 1:m:1, and m is greater than 1.

Optionally, when the computer executable instructions stored in thestorage medium are being executed by the processor, the determiningcenters of candidate position detection patterns in the QR code imageincludes: determining, from row pixels, first pixel arrangements inwhich consecutive arrangement ratios of a first-type pixel, asecond-type pixel, and a first-type pixel satisfy the firstpredetermined ratio; determining, from column pixels, second pixelarrangements in which consecutive arrangement ratios of a first-typepixel, a second-type pixel, and a first-type pixel satisfy the secondpredetermined ratio; and determining the centers of the candidateposition detection patterns based on centers of the first pixelarrangements and centers of the second pixel arrangements.

Optionally, when the computer executable instructions stored in thestorage medium are being executed by the processor, the determining,from the identified candidate position detection patterns, patterns thatsatisfy a QR code image positioning rule includes: determining, from theidentified candidate position detection patterns, candidate positiondetection patterns that satisfy at least one of a first selectioncondition and a second selection condition, where the first selectioncondition includes that at least one of a quantity of first-type pixelsand a quantity of second-type pixels within a predetermined areaadjacent to the center satisfies a predetermined threshold range, andthe second selection condition includes that a consecutive arrangementratio of a first-type pixel, a second-type pixel, a first-type pixel, asecond-type pixel, and a first-type pixel in a third pixel arrangementthat passes through the center satisfies a third predetermined ratio;and determining, from the candidate position detection patterns thatsatisfy at least one of the first selection condition and the secondselection condition, the patterns that satisfy the QR code positioningrule.

Optionally, the positioning rule includes that the shortest two linesamong the three lines that connect centers of three position detectionpatterns are perpendicular with each other and are equal in length. Whenthe computer executable instructions stored in the storage medium arebeing executed by the processor, the determining, from the candidateposition detection patterns that satisfy at least one of the firstselection condition and the second selection condition, the patternsthat satisfy the QR code positioning rule includes: forming, from thecandidate position detection patterns that satisfy at least one of thefirst selection condition and the second selection condition, multiplegroups of candidate position detection patterns by using each threecandidate position detection patterns as one group; determining whethereach group of candidate position detection patterns satisfies thepositioning rule; and using at least one group of candidate positiondetection patterns that satisfy the positioning rule as the positiondetection patterns of the QR code image.

Optionally, when the computer executable instructions stored in thestorage medium are being executed by the processor, the determining,from the candidate position detection patterns that satisfy at least oneof the first selection condition and the second selection condition, thepatterns that satisfy the QR code positioning rule includes: forming,from the candidate position detection patterns that satisfy at least oneof the first selection condition and the second selection condition,multiple groups of candidate position detection patterns by using eachthree candidate position detection patterns as one group; determininggeometric parameters of a triangle formed by connection lines of centersof three candidate position detection patterns in each group ofcandidate position detection patterns and a standard deviation of areasof the three candidate position detection patterns, where the geometricparameters include a value of an angle between two short connectionlines in the triangle and a length difference between the two shortconnection lines; and determining, based on the value of the angle, thelength difference, and the standard deviation, the patterns that satisfythe QR code positioning rule.

Optionally, when the computer executable instructions stored in thestorage medium are being executed by the processor, the determining,based on the value of the angle, the length difference, and the standarddeviation, the patterns that satisfy the QR code positioning ruleincludes: calculating a score of each group of candidate positiondetection patterns based on the value of the angle, the lengthdifference, and the standard deviation by using the following equation;and comparing the score of each group of candidate position detectionpatterns with a predetermined score, and determining, based on acomparison result, the patterns that satisfy the QR code positioningrule, where

${f_{i} = \frac{1}{1 + e^{{ax}_{i} + {by}_{i} + {cz}_{i} + d}}}.$

In the previous equation, a, b, c, and d are all constants, x_(i)represents a value of an angle between two short connection lines in atriangle formed by connection lines of centers of an ith group ofcandidate position detection patterns, y_(i) represents a lengthdifference between the two short connection lines in the triangle formedby the ith group of candidate position detection patterns, z_(i)represents a standard deviation of areas of three candidate positiondetection patterns in the ith group of candidate position detectionpatterns, and f_(i) represents a score of the ith group of candidateposition detection patterns.

Further, an implementation of the present application further provides astorage medium, configured to store computer executable instructions. Ina specific implementation, the storage medium can be a USB flash drive,an optical disc, a hard disk, etc. When the computer executableinstructions stored in the storage medium are being executed by aprocessor, the following procedures can be implemented: determining,from a QR code image that includes first-type pixels and second-typepixels, centers of candidate position detection patterns in the QR codeimage based on a predetermined row pixel detection rule and apredetermined column pixel detection rule, where the row pixel detectionrule includes that a quantity of consecutively arranged first-typepixels or a quantity of consecutively arranged second-type pixelsreaches a first predetermined threshold, and the column pixel detectionrule includes that a quantity of consecutively arranged first-typepixels or a quantity of consecutively arranged second-type pixelsreaches a second predetermined threshold; identifying the correspondingcandidate position detection patterns based on the determined centers ofthe candidate position detection patterns; and determining, from theidentified candidate position detection patterns, patterns that satisfya QR code image positioning rule, and using the determined patterns asposition detection patterns of the QR code image.

Optionally, when the computer executable instructions stored in thestorage medium are being executed by the processor, the firstpredetermined threshold is equal to the second predetermined threshold.

Further, an implementation of the present application further provides astorage medium, configured to store computer executable instructions. Ina specific implementation, the storage medium can be a USB flash drive,an optical disc, a hard disk, etc. When the computer executableinstructions stored in the storage medium are being executed by aprocessor, the following procedures can be implemented: determining,from a QR code image that includes first-type pixels and second-typepixels, centers of candidate position detection patterns in the QR codeimage based on a predetermined pixel detection rule, where the pixeldetection rule includes that a consecutive arrangement ratio of afirst-type pixel, a second-type pixel, and a first-type pixel satisfiesa predetermined ratio; identifying the corresponding candidate positiondetection patterns based on the determined centers of the candidateposition detection patterns; and determining, from the identifiedcandidate position detection patterns, patterns that satisfy a QR codeimage positioning rule, and using the determined patterns as positiondetection patterns of the QR code image.

Optionally, when the computer executable instructions stored in thestorage medium are being executed by the processor, the predeterminedratio is 1:5:1.

Optionally, when the computer executable instructions stored in thestorage medium are being executed by the processor, the first-type pixelis a black pixel or a blue pixel, and the second-type pixel is a pixelwhose color difference with the first-type pixel exceeds a specifiedthreshold.

In this implementation of the present application, after the executableinstructions stored in the storage medium are executed, the candidateposition detection patterns in the QR code are first determined based onthe arrangement ratio of a first-type pixel, a second-type pixel, and afirst-type pixel or based on the quantity of consecutively arrangedfirst-type pixels or the quantity of consecutively arranged second-typepixels, which has certain fault tolerance. As such, the candidateposition detection patterns can be identified even if the positiondetection patterns of the QR code are stained or are weak in brightness,thereby improving identification validity of the candidate positiondetection patterns. In addition, after the candidate position detectionpatterns are identified by using the previous method, the positiondetection patterns of the QR code are determined from the identifiedcandidate position detection patterns, so that accuracy is relativelyhigh.

In the 1990s, whether a technical improvement is a hardware improvement(for example, an improvement to a circuit structure, such as a diode, atransistor, or a switch) or a software improvement (an improvement to amethod procedure) can be clearly distinguished. However, as technologiesdevelop, current improvements to many method procedures can beconsidered as direct improvements to hardware circuit structures. Almostall designers program an improved method procedure into a hardwarecircuit, to obtain a corresponding hardware circuit structure.Therefore, a method procedure can be improved by using a hardware entitymodule. For example, a programmable logic device (PLD) (for example, afield programmable gate array (FPGA)) is such an integrated circuit, anda logical function of the PLD is determined by a user through deviceprogramming. A designer performs programming to “integrate” a digitalsystem to a single PLD, without requiring a chip manufacturer to designand manufacture a dedicated integrated circuit chip. In addition, atpresent, instead of manually manufacturing an integrated circuit chip,this type of programming is mostly implemented by using “logic compiler”software. The “logic compiler” software is similar to a softwarecompiler used to develop and write a program. Original code needs to bewritten in a particular programming language before being compiled. Thelanguage is referred to as a hardware description language (HDL). Thereare many HDLs, such as the Advanced Boolean Expression Language (ABEL),the Altera Hardware Description Language (AHDL), Confluence, the CornellUniversity Programming Language (CUPL), HDCal, the Java HardwareDescription Language (JHDL), Lava, Lola, MyHDL, PALASM, and the RubyHardware Description Language (RHDL). The very-high-speed integratedcircuit hardware description language (VHDL) and Verilog are mostcommonly used at present. A person skilled in the art should alsounderstand that a hardware circuit that implements a logical methodprocedure can be readily obtained provided that the method procedure islogically programmed by using several described hardware descriptionlanguages and is programmed into an integrated circuit.

A controller can be implemented by using any appropriate method. Forexample, the controller can be in a form of a microprocessor or aprocessor, or a computer-readable medium that stores computer readableprogram code (such as software or firmware) that can be executed by themicroprocessor or the processor, a logic gate, a switch, anapplication-specific integrated circuit (ASIC), a programmable logiccontroller, or a built-in microprocessor. Examples of the controllerinclude but are not limited to the following microprocessors: ARC 625D,Atmel AT91SAM, Microchip PIC18F26K20, and Silicone Labs C8051F320. Thememory controller can also be implemented as a part of control logic ofthe memory. A person skilled in the art also knows that, in addition toimplementing the controller by using the computer readable program code,logic programming can be performed on method steps to allow thecontroller to implement the same function in forms of the logic gate,the switch, the application-specific integrated circuit, theprogrammable logic controller, and the built-in microcontroller.Therefore, the controller can be considered as a hardware component, andan apparatus configured to implement various functions in the controllercan also be considered as a structure in the hardware component.Alternatively, the apparatus configured to implement various functionscan even be considered as both a software module implementing the methodand a structure in the hardware component.

The system, apparatus, module, or unit illustrated in the previousimplementations can be specifically implemented by using a computer chipor an entity, or can be implemented by using a product having a certainfunction. A typical implementation device is a computer. Specifically,the computer can be, for example, a personal computer, a laptopcomputer, a cellular phone, a camera phone, a smartphone, a personaldigital assistant, a media player, a navigation device, an email device,a game console, a tablet computer, or a wearable device, or acombination of any of these devices.

For ease of description, the previous apparatus is divided to variousunits based on functions for description when the previous apparatus isdescribed. Certainly, when the present application is implemented, thefunctions of the units can be implemented in one or more pieces ofsoftware and/or hardware.

A person skilled in the art should understand that the implementationsof the present application can be provided as a method, a system, or acomputer program product. Therefore, the present application can use aform of hardware only implementations, software only implementations, orimplementations with a combination of software and hardware. Inaddition, the present application can use a form of a computer programproduct that is implemented on one or more computer-usable storage media(including but not limited to a magnetic disk memory, a CD-ROM, anoptical memory, etc.) that include computer-usable program code.

The present application is described with reference to the flowchartsand/or block diagrams of the method, the device (system), and thecomputer program product according to the implementations of the presentapplication. It is worthwhile to note that computer program instructionscan be used to implement each process and/or each block in theflowcharts and/or the block diagrams and a combination of a processand/or a block in the flowcharts and/or the block diagrams. Thesecomputer program instructions can be provided for a general-purposecomputer, a dedicated computer, an embedded processor, or a processor ofother programmable data processing devices to generate a machine, sothat the instructions executed by the computer or the processor of otherprogrammable data processing devices generate an apparatus forimplementing a specific function in one or more processes in theflowcharts and/or in one or more blocks in the block diagrams.

These computer program instructions can be stored in a computer readablememory that can instruct the computer or the other programmable dataprocessing devices to work in a specific way, so that the instructionsstored in the computer readable memory generate an artifact thatincludes an instruction apparatus. The instruction apparatus implementsa specific function in one or more processes in the flowcharts and/or inone or more blocks in the block diagrams.

These computer program instructions can be loaded onto the computer orother programmable data processing devices, so that a series ofoperations and steps are performed on the computer or the otherprogrammable devices, thereby generating computer-implementedprocessing. Therefore, the instructions executed on the computer orother programmable devices provide steps for implementing a specificfunction in one or more processes in the flowcharts and/or in one ormore blocks in the block diagrams.

In a typical configuration, a computing device includes one or moreprocessors (CPUs), input/output interfaces, network interfaces, andmemories.

The memory may include a non-persistent memory, a random access memory(RAM), and/or a nonvolatile memory in a computer readable medium, forexample, a read-only memory (ROM) or a flash memory (flash RAM). Thememory is an example of the computer readable medium.

The computer readable medium includes persistent, non-persistent,movable, and unmovable media that can store information by using anymethod or technology. The information can be a computer readableinstruction, a data structure, a program module, or other data. Examplesof the computer storage medium include but are not limited to aphase-change RAM (PRAM), a static RAM (SRAM), a dynamic RAM (DRAM), aRAM of another type, a ROM, an electrically erasable programmable readonly memory (EEPROM), a flash memory or another memory technology, acompact disc read-only memory (CD-ROM), a digital versatile disc (DVD)or another optical storage, a cassette, a cassette magnetic disk storageor another magnetic storage device, or any other non-transmissionmedium. The computer storage medium can be configured to storeinformation that can be accessed to a computing device. As described inthe present application, the computer readable medium does not includecomputer readable transitory media such as a modulated data signal and acarrier.

It is worthwhile to further note that, the terms “comprise” and“include”, or any other variants thereof are intended to cover anon-exclusive inclusion, so that a process, method, product or devicethat includes a list of elements not only includes those elements butalso includes other elements that are not expressly listed, or furtherincludes elements inherent to such process, method, product or device.Without more constraints, an element preceded by “includes a . . . ”does not preclude the existence of additional identical elements in theprocess, method, product or device that includes the element.

A person skilled in the art should understand that the implementationsof the present application can be provided as a method, a system, or acomputer program product. Therefore, the present application can use aform of hardware only implementations, software only implementations, orimplementations with a combination of software and hardware. Inaddition, the present application can use a form of a computer programproduct that is implemented on one or more computer-usable storage media(including but not limited to a magnetic disk memory, a CD-ROM, anoptical memory, etc.) that include computer-usable program code.

The present application can be described in the general context of acomputer executable instruction executed by a computer, for example, aprogram module. Generally, the program module includes a routine, aprogram, an object, a component, a data structure, etc. executing aspecific task or implementing a specific abstract data type. The presentapplication can also be practiced in distributed computing environments.In the distributed computing environments, tasks are performed by remoteprocessing devices connected through a communications network. In adistributed computing environment, the program module can be located inboth local and remote computer storage media including storage devices.

The implementations of the present specification are described in aprogressive way. For same or similar parts of the implementations,mutual references can be made to the implementations. Eachimplementation focuses on a difference from other implementations.Particularly, a system implementation is basically similar to a methodimplementation, and therefore is described briefly. For related parts,references can be made to related descriptions in the methodimplementation.

The previous implementations are merely implementations of the presentapplication, and are not intended to limit the present application. Aperson skilled in the art can make various modifications and changes tothe present application. Any modification, equivalent replacement,improvement, etc. made without departing from the spirit and principleof the present application shall fall within the scope of the claims ofthe present application.

What is claimed is:
 1. A computer-implemented method, comprising:determining, by a computing device, from a QR code image that comprisesfirst-type pixels and second-type pixels, centers of candidate positiondetection patterns in the QR code image based on a predetermined pixeldetection rule, wherein the predetermined pixel detection rule comprisesthat a consecutive arrangement ratio of the first-type pixels, thesecond-type pixels, and the first-type pixels satisfies a predeterminedratio; identifying, by the computing device, the candidate positiondetection patterns based on the centers of the candidate positiondetection patterns; determining, by the computing device, from thecandidate position detection patterns, a set of patterns that satisfiesa QR code image positioning rule; and using, by the computing device,the set of patterns as position detection patterns of the QR code image.2. The computer-implemented method of claim 1, wherein the predeterminedratio is 1:5:1.
 3. The computer-implemented method of claim 1, wherein apixel of the first-type pixels is a black pixel or a blue pixel, and apixel of the second-type pixels is a pixel whose color difference withthe pixel of the first-type pixels exceeds a specified threshold.
 4. Thecomputer-implemented method of claim 1, wherein the predetermined pixeldetection rule comprises a row pixel detection rule and a column pixeldetection rule, and wherein the row pixel detection rule comprises thata first consecutive arrangement ratio of the first-type pixels, thesecond-type pixels, and the first-type pixels satisfies a firstpredetermined ratio, and the column pixel detection rule comprises thata second consecutive arrangement ratio of the first-type pixels, thesecond-type pixels, and the first-type pixels satisfies a secondpredetermined ratio.
 5. The computer-implemented method of claim 4,wherein the first predetermined ratio is 1:n:1, and n is greater than 1;and the second predetermined ratio is 1:m:1, and m is greater than
 1. 6.The computer-implemented method of claim 4, wherein determining thecenters of the candidate position detection patterns in the QR codeimage comprises: determining, from row pixels of the QR code image,first pixel arrangements, wherein in each one of the first pixelarrangements, the first consecutive arrangement ratio of the first-typepixels, the second-type pixels, and the first-type pixels satisfies thefirst predetermined ratio; determining, from column pixels of the QRcode image, second pixel arrangements, wherein in each one of the secondpixel arrangements, the second consecutive arrangement ratio of thefirst-type pixels, the second-type pixels, and the first-type pixelssatisfies the second predetermined ratio; and determining the centers ofthe candidate position detection patterns based on centers of the firstpixel arrangements and centers of the second pixel arrangements.
 7. Thecomputer-implemented method of claim 4, wherein determining the set ofpatterns that satisfies the QR code image positioning rule comprises:determining, from the candidate position detection patterns, a final setof candidate position detection patterns that satisfies at least one ofa first selection condition and a second selection condition, whereinthe first selection condition comprises that at least one of a quantityof the first-type pixels and a quantity of the second-type pixels withina predetermined area adjacent to the center of each candidate positiondetection pattern in the final set of candidate position detectionpatterns satisfies a predetermined threshold range, and wherein thesecond selection condition comprises that a third consecutivearrangement ratio of the first-type pixels, the second-type pixels, thefirst-type pixels, the second-type pixels, and the first-type pixels ina third pixel arrangement that passes through the center satisfies athird predetermined ratio; and determining, from the final set ofcandidate position detection patterns that satisfies at least one of thefirst selection condition and the second selection condition, the set ofpatterns that satisfies the QR code image positioning rule.
 8. Anon-transitory, computer-readable medium storing one or moreinstructions executable by a computer system to perform operationscomprising: determining, by a computing device, from a QR code imagethat comprises first-type pixels and second-type pixels, centers ofcandidate position detection patterns in the QR code image based on apredetermined pixel detection rule, wherein the predetermined pixeldetection rule comprises that a consecutive arrangement ratio of thefirst-type pixels, the second-type pixels, and the first-type pixelssatisfies a predetermined ratio; identifying, by the computing device,the candidate position detection patterns based on the centers of thecandidate position detection patterns; determining, by the computingdevice, from the candidate position detection patterns, a set ofpatterns that satisfies a QR code image positioning rule; and using, bythe computing device, the set of patterns as position detection patternsof the QR code image.
 9. The non-transitory, computer-readable medium ofclaim 8, wherein the predetermined ratio is 1:5:1.
 10. Thenon-transitory, computer-readable medium of claim 8, wherein a pixel ofthe first-type pixels is a black pixel or a blue pixel, and a pixel ofthe second-type pixels is a pixel whose color difference with the pixelof the first-type pixels exceeds a specified threshold.
 11. Thenon-transitory, computer-readable medium of claim 8, wherein thepredetermined pixel detection rule comprises a row pixel detection ruleand a column pixel detection rule, and wherein the row pixel detectionrule comprises that a first consecutive arrangement ratio of thefirst-type pixels, the second-type pixels, and the first-type pixelssatisfies a first predetermined ratio, and the column pixel detectionrule comprises that a second consecutive arrangement ratio of thefirst-type pixels, the second-type pixels, and the first-type pixelssatisfies a second predetermined ratio.
 12. The non-transitory,computer-readable medium of claim 11, wherein the first predeterminedratio is 1:n:1, and n is greater than 1; and the second predeterminedratio is 1:m:1, and m is greater than
 1. 13. The non-transitory,computer-readable medium of claim 11, wherein determining the centers ofthe candidate position detection patterns in the QR code imagecomprises: determining, from row pixels of the QR code image, firstpixel arrangements, wherein in each one of the first pixel arrangements,the first consecutive arrangement ratio of the first-type pixels, thesecond-type pixels, and the first-type pixels satisfies the firstpredetermined ratio; determining, from column pixels of the QR codeimage, second pixel arrangements, wherein in each one of the secondpixel arrangements, the second consecutive arrangement ratio of thefirst-type pixels, the second-type pixels, and the first-type pixelssatisfies the second predetermined ratio; and determining the centers ofthe candidate position detection patterns based on centers of the firstpixel arrangements and centers of the second pixel arrangements.
 14. Thenon-transitory, computer-readable medium of claim 11, whereindetermining the set of patterns that satisfies the QR code imagepositioning rule comprises: determining, from the candidate positiondetection patterns, a final set of candidate position detection patternsthat satisfies at least one of a first selection condition and a secondselection condition, wherein the first selection condition comprisesthat at least one of a quantity of the first-type pixels and a quantityof the second-type pixels within a predetermined area adjacent to thecenter of each candidate position detection pattern in the final set ofcandidate position detection patterns satisfies a predeterminedthreshold range, and wherein the second selection condition comprisesthat a third consecutive arrangement ratio of the first-type pixels, thesecond-type pixels, the first-type pixels, the second-type pixels, andthe first-type pixels in a third pixel arrangement that passes throughthe center satisfies a third predetermined ratio; and determining, fromthe final set of candidate position detection patterns that satisfies atleast one of the first selection condition and the second selectioncondition, the set of patterns that satisfies the QR code imagepositioning rule.
 15. A computer-implemented system, comprising: one ormore computers; and one or more computer memory devices interoperablycoupled with the one or more computers and having tangible,non-transitory, machine-readable media storing one or more instructionsthat, when executed by the one or more computers, perform operationscomprising: determining, by a computing device, from a QR code imagethat comprises first-type pixels and second-type pixels, centers ofcandidate position detection patterns in the QR code image based on apredetermined pixel detection rule, wherein the predetermined pixeldetection rule comprises that a consecutive arrangement ratio of thefirst-type pixels, the second-type pixels, and the first-type pixelssatisfies a predetermined ratio; identifying, by the computing device,the candidate position detection patterns based on the centers of thecandidate position detection patterns; determining, by the computingdevice, from the candidate position detection patterns, a set ofpatterns that satisfies a QR code image positioning rule; and using, bythe computing device, the set of patterns as position detection patternsof the QR code image.
 16. The computer-implemented system of claim 15,wherein the predetermined ratio is 1:5:1.
 17. The computer-implementedsystem of claim 15, wherein a pixel of the first-type pixels is a blackpixel or a blue pixel, and a pixel of the second-type pixels is a pixelwhose color difference with the pixel of the first-type pixels exceeds aspecified threshold.
 18. The computer-implemented system of claim 15,wherein the predetermined pixel detection rule comprises a row pixeldetection rule and a column pixel detection rule, and wherein the rowpixel detection rule comprises that a first consecutive arrangementratio of the first-type pixels, the second-type pixels, and thefirst-type pixels satisfies a first predetermined ratio, and the columnpixel detection rule comprises that a second consecutive arrangementratio of the first-type pixels, the second-type pixels, and thefirst-type pixels satisfies a second predetermined ratio.
 19. Thecomputer-implemented system of claim 18, wherein the first predeterminedratio is 1:n:1, and n is greater than 1; and the second predeterminedratio is 1:m:1, and m is greater than
 1. 20. The computer-implementedsystem of claim 18, wherein determining the centers of the candidateposition detection patterns in the QR code image comprises: determining,from row pixels of the QR code image, first pixel arrangements, whereinin each one of the first pixel arrangements, the first consecutivearrangement ratio of the first-type pixels, the second-type pixels, andthe first-type pixels satisfies the first predetermined ratio;determining, from column pixels of the QR code image, second pixelarrangements, wherein in each one of the second pixel arrangements, thesecond consecutive arrangement ratio of the first-type pixels, thesecond-type pixels, and the first-type pixels satisfies the secondpredetermined ratio; and determining the centers of the candidateposition detection patterns based on centers of the first pixelarrangements and centers of the second pixel arrangements.